package com.flowplan.websocket.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * 用户状态消息DTO
 * 用于WebSocket实时用户状态同步
 */
@Data
public class UserStatusMessage {
    
    /**
     * 用户ID
     */
    private String userId;
    
    /**
     * 用户名
     */
    private String username;
    
    /**
     * 项目ID
     */
    private Long projectId;
    
    /**
     * 在线状态
     */
    private Boolean online;
    
    /**
     * 用户角色
     */
    private String role;
    
    /**
     * 当前操作的资源ID
     */
    private String currentResourceId;
    
    /**
     * 用户状态 (ACTIVE, IDLE, EDITING)
     */
    private String status;
    
    /**
     * 时间戳
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timestamp;
    
    /**
     * 最后活动时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime lastActivity;
    
    /**
     * 用户头像URL
     */
    private String avatarUrl;
    
    /**
     * 附加信息
     */
    private String metadata;
    
    public UserStatusMessage() {
        this.timestamp = LocalDateTime.now();
        this.lastActivity = LocalDateTime.now();
    }
    
    public UserStatusMessage(String userId, Long projectId, Boolean online) {
        this();
        this.userId = userId;
        this.projectId = projectId;
        this.online = online;
    }
}